home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectInput / DIConfig / cdiacpage.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-08  |  6.1 KB  |  193 lines

  1. //-----------------------------------------------------------------------------
  2. // File: cdiacpage.h
  3. //
  4. // Desc: CDIDeviceActionConfigPage implements the page object used by the UI.
  5. //       A page covers the entire UI minus the device tabs and the bottons at
  6. //       the bottom.  The information window, player combo-box, genre combo-
  7. //       box, action list tree, and device view window are all managed by
  8. //       the page.
  9. //
  10. // Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
  11. //-----------------------------------------------------------------------------
  12.  
  13. #ifdef FORWARD_DECLS
  14.  
  15.  
  16.     class CDIDeviceActionConfigPage;
  17.  
  18.  
  19. #else // FORWARD_DECLS
  20.  
  21. #ifndef __CDIACPAGE_H__
  22. #define __CDIACPAGE_H__
  23.  
  24. // For WINMM.DLL
  25. typedef MMRESULT (WINAPI *FUNCTYPE_timeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
  26. extern HINSTANCE g_hWinMmDLL;
  27. extern FUNCTYPE_timeSetEvent g_fptimeSetEvent;
  28.  
  29. //implementation class
  30. class CDIDeviceActionConfigPage : public IDIDeviceActionConfigPage, public CDeviceUINotify, public CFlexWnd
  31. {
  32. public:
  33.  
  34.     //IUnknown fns
  35.     STDMETHOD (QueryInterface) (REFIID iid, LPVOID *ppv);
  36.     STDMETHOD_(ULONG, AddRef) ();
  37.     STDMETHOD_(ULONG, Release) ();
  38.  
  39.     //IDirectInputActionConfigPage
  40.     STDMETHOD (Create) (DICFGPAGECREATESTRUCT *pcs);
  41.     STDMETHOD (Show) (LPDIACTIONFORMATW lpDiActFor);
  42.     STDMETHOD (Hide) ();
  43.  
  44.     // layout edit mode
  45.     STDMETHOD (SetEditLayout) (BOOL bEditLayout);
  46.  
  47.  
  48.     // Set the info box text
  49.     STDMETHOD (SetInfoText) (int iCode);
  50.  
  51.     // Unacquire and Reacquire the device for page's purposes
  52.     // (the configwnd needs to do this around SetActionMap() calls)
  53.     STDMETHOD (Unacquire) ();
  54.     STDMETHOD (Reacquire) ();
  55.  
  56.     //construction/destruction
  57.     CDIDeviceActionConfigPage();
  58.     ~CDIDeviceActionConfigPage();
  59.  
  60.  
  61.     // dialog window message handlers
  62. /*    BOOL OnInitDialog(HWND hWnd, HWND hwndFocus);
  63.     BOOL OnCommand(WPARAM wParam, LPARAM lParam);
  64.     LRESULT OnNotify(WPARAM wParam, LPARAM lParam);
  65.     void OnPaint(HDC hDC);
  66.     void OnClick(POINT point, WPARAM, BOOL bLeft);*/
  67.  
  68. protected:
  69.     virtual void OnInit();
  70.     virtual void OnPaint(HDC hDC);
  71.     virtual void OnClick(POINT point, WPARAM fwKeys, BOOL bLeft);
  72.     virtual void OnMouseOver(POINT point, WPARAM fwKeys);
  73.     virtual LRESULT WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  74.  
  75. private:
  76.     enum CONFIGSTATE {CFGSTATE_NORMAL, CFGSTATE_ASSIGN};
  77.  
  78. //    HWND m_hWnd; // handle to the page dialog window
  79.     LONG m_cRef; //reference count
  80.     LPDIACTIONFORMATW m_lpDiac;
  81.     DIDEVICEINSTANCEW m_didi;
  82.     LPDIRECTINPUTDEVICE8W m_lpDID;
  83.     CUIGlobals *m_puig;
  84.     IDIConfigUIFrameWindow *m_pUIFrame;
  85.     CONFIGSTATE m_State;
  86.  
  87.     // device ui
  88.     CDeviceUI *m_pDeviceUI;
  89.     CDeviceControl *m_pCurControl;
  90.     virtual void DeviceUINotify(const DEVICEUINOTIFY &);
  91.     virtual BOOL IsControlMapped(CDeviceControl *);
  92.  
  93.     // ui logic
  94.     void SetCurrentControl(CDeviceControl *pControl);
  95.     void NullAction(LPDIACTIONW lpac);
  96.     void UnassignControl(CDeviceControl *pControl);
  97.     friend void CallUnassignControl(CDeviceControl *pControl, LPVOID pVoid, BOOL bFixed);
  98.     void UnassignAction(LPDIACTIONW lpac);
  99.     void UnassignSpecificAction(LPDIACTIONW lpac);
  100.     void UnassignActionsAssignedTo(const GUID &guidInstance, DWORD dwOffset);
  101.     void AssignCurrentControlToAction(LPDIACTIONW lpac);
  102.     void ActionClick(LPDIACTIONW lpac);
  103.     void EnterAssignState();
  104.     void ExitAssignState();
  105.     void UnassignCallout();
  106.     void SetAppropriateDefaultText();
  107.  
  108.     void GlobalUnassignControlAt(const GUID &, DWORD);
  109.     void SetControlAssignments();
  110.  
  111.     void ShowCurrentControlAssignment();
  112.  
  113.     CBitmap *m_pbmRelAxesGlyph;
  114.     CBitmap *m_pbmAbsAxesGlyph;
  115.     CBitmap *m_pbmButtonGlyph;
  116.     CBitmap *m_pbmHatGlyph;
  117.     CBitmap *m_pbmCheckGlyph;
  118.     CBitmap *m_pbmCheckGlyphDark;
  119.     CBitmap *m_pbmIB;
  120.     CBitmap *m_pbmIB2;
  121.     void InitResources();
  122.     void FreeResources();
  123.  
  124.     RECT m_rectIB;
  125.     RECT m_rectIBLeft;
  126.     RECT m_rectIBRight;
  127.     LPTSTR m_tszIBText;
  128.     POINT m_ptIBOffset;
  129.     POINT m_ptIBOffset2;
  130.     RECT m_rectIBText;
  131.     void InitIB();
  132.  
  133.     CViewSelWnd m_ViewSelWnd;
  134.     void DoViewSel();
  135.  
  136.     CFlexTree m_Tree;
  137.     CFTItem *m_pRelAxesParent, *m_pAbsAxesParent, *m_pButtonParent, *m_pHatParent, *m_pUnknownParent;
  138.     void ClearTree();
  139.     void InitTree(BOOL bForceInit = FALSE);
  140.     DWORD m_dwLastControlType;
  141.  
  142.     CFTItem *GetItemForActionAssignedToControl(CDeviceControl *pControl);
  143.     int GetNumItemLpacs(CFTItem *pItem);
  144.     LPDIACTIONW GetItemLpac(CFTItem *pItem, int i = 0);
  145.     typedef CArray<LPDIACTIONW, LPDIACTIONW &> RGLPDIACW;
  146.     // GetItemWithActionNameAndSemType returns an item with the specified action name and semantic type.  NULL if none.
  147.     CFTItem *GetItemWithActionNameAndSemType(LPCWSTR acname, DWORD dwSemantic);
  148.     BOOL IsActionAssignedHere(int index);
  149.  
  150.     // quick fix for offset->objid change:
  151.     void SetInvalid(LPDIACTIONW);
  152.     DWORD GetOffset(LPDIACTIONW);
  153.     void SetOffset(LPDIACTIONW, DWORD);
  154.     bidirlookup<DWORD, DWORD> offset_objid;
  155.     HRESULT InitLookup();
  156.  
  157.     // dropdowns
  158.     CFlexComboBox m_UserNames, m_Genres;
  159.  
  160.     // Information window
  161.     CFlexInfoBox m_InfoBox;
  162.  
  163.     // Sort Assigned check box for keyboard devices
  164.     CFlexCheckBox m_CheckBox;
  165.  
  166.     // device control
  167.     DWORD m_cbDeviceDataSize;
  168.     DWORD *m_pDeviceData[2];
  169.     int m_nOnDeviceData;
  170.     BOOL m_bFirstDeviceData;
  171.     void InitDevice();
  172.     void DeviceTimer();
  173.     static void CALLBACK DeviceTimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);
  174.     void DeviceDelta(DWORD *pData, DWORD *pOldData);
  175.     void AxisDelta(const DIDEVICEOBJECTINSTANCEW &doi, BOOL data, BOOL old);
  176.     void ButtonDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  177.     void PovDelta(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD old);
  178.     void ActivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  179.     void DeactivateObject(const DIDEVICEOBJECTINSTANCEW &doi);
  180.     bidirlookup<DWORD, int> objid_avai;
  181.     typedef CArray<int, int &> AxisValueArray;
  182.     CArray<AxisValueArray, AxisValueArray &> m_AxisValueArray;
  183.     void StoreAxisDeltaAndCalcSignificance(const DIDEVICEOBJECTINSTANCEW &doi, DWORD data, DWORD olddata, BOOL &bSig, BOOL &bOldSig);
  184.  
  185.     // page index
  186.     int m_nPageIndex;
  187. };
  188.  
  189.  
  190. #endif //__CDIACPAGE_H__
  191.  
  192. #endif // FORWARD_DECLS
  193.